layui.use(['common','layer','table','form',],function(){
	var $ = layui.$,
    	layer = layui.layer,
    	form = layui.form,
    	common = layui.common,
    	table = layui.table;
	
	
	common.larryCmsLoadJq('/LarryMS/business/common/ztree/js/jquery.ztree.all.js', function() {
		var zTreeObj,
		setting = {
				data: {  
                    simpleData: {  
                        enable: true  
                    }  
                } ,
			callback: {
				onClick: zTreeOnClick
			}
		}
		
		var $j = jQuery.noConflict();
		
		$.post("/systemsetup/permissionsmanage/permissions/selectPermissions","",function(result){
			zTreeObj = $j.fn.zTree.init($("#treeDemo"), setting, result.data);
		});
		
		function zTreeOnClick(event, treeId, treeNode) {
			$("#pid").val(treeNode.id);
		};
	});
	 //监听提交
    form.on('submit(PermissionsAdd)', function(data){
   
	   $.post("/systemsetup/permissionsmanage/permissions/adminPermission",data.field,function(result){
		   if (result.status == 200) {
			   location.reload();
		   } else {
			   layer.msg(result.msg);
		   } 
	   });
	  
	   
	   return false;
    });
	
   
    
    
});